Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pick_batchsize #1545

Closed
wants to merge 12 commits into from
Closed

Implement pick_batchsize #1545

wants to merge 12 commits into from

Conversation

gdalle
Copy link
Contributor

@gdalle gdalle commented Jun 18, 2024

Fix #1542 by implementing a constant heuristic for picking chunk size.

src/utils.jl Outdated Show resolved Hide resolved
src/utils.jl Outdated Show resolved Hide resolved
@gdalle gdalle requested a review from vchuravy June 21, 2024 15:19
src/utils.jl Outdated Show resolved Hide resolved
@gdalle gdalle requested a review from wsmoses June 27, 2024 13:13
@gdalle
Copy link
Contributor Author

gdalle commented Jun 27, 2024

Should this be renamed to pick_batchsize? On the one hand, the type is BatchDuplicated, but on the other hand, jacobian and gradient call it chunk

@wsmoses
Copy link
Member

wsmoses commented Jun 27, 2024

Sure, batchsize sgtm.

@wsmoses
Copy link
Member

wsmoses commented Jun 27, 2024

Otherwise, this looks good to me once test pass

@gdalle gdalle changed the title Implement pick_chunksize Implement pick_batchsize Jun 28, 2024
@gdalle
Copy link
Contributor Author

gdalle commented Jun 28, 2024

I think test failures are unrelated? The tests I introduced pass locally

@gdalle
Copy link
Contributor Author

gdalle commented Jul 2, 2024

is this acceptable? it's hard to know given all the failing tests

@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.63%. Comparing base (037dfed) to head (a44ae9d).
Report is 134 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
+ Coverage   67.50%   71.63%   +4.12%     
==========================================
  Files          31       32       +1     
  Lines       12668    13816    +1148     
==========================================
+ Hits         8552     9897    +1345     
+ Misses       4116     3919     -197     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wsmoses
Copy link
Member

wsmoses commented Aug 4, 2024

@gdalle CI here seems really just blocked by this PR.

e.g.

BatchMixedDuplicated vector{float64} call |    3      3
Test Summary: | Pass  Total
TypeTree      |   20     20
ERROR: LoadError: LoadError: ArgumentError: Package EnzymeCore not found in current path:
- Run `import Pkg; Pkg.add("EnzymeCore")` to install the EnzymeCore package.

Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:893
 [2] include(fname::String)
   @ Base.MainInclude ./client.jl:444
 [3] top-level scope
   @ ~/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:87
 [4] include(fname::String)
   @ Base.MainInclude ./client.jl:444
 [5] top-level scope
   @ none:6
in expression starting at /home/runner/work/Enzyme.jl/Enzyme.jl/test/utils.jl:2

@gdalle
Copy link
Contributor Author

gdalle commented Aug 5, 2024

My bad, I thought EnzymeCore was available for testing. I removed it from the test file

@gdalle
Copy link
Contributor Author

gdalle commented Aug 29, 2024

@wsmoses this should be good to go?

@gdalle
Copy link
Contributor Author

gdalle commented Sep 26, 2024

@vchuravy this looks like an easy merge?

src/utils.jl Outdated Show resolved Hide resolved
@gdalle
Copy link
Contributor Author

gdalle commented Oct 8, 2024

Sorry I inadvertently formatted the code, will fix the diff

@gdalle
Copy link
Contributor Author

gdalle commented Oct 10, 2024

Is this mergeable?

@wsmoses
Copy link
Member

wsmoses commented Oct 11, 2024

sorry for all the constant shenanigans, but sadly this now has a merge conflict. I'll merge right after and ping me if its not (sorry this functionality isn't currently used in Enzyme or fixes an issue so I keep forgetting to hit merge after walking away as CI starts)

@gdalle
Copy link
Contributor Author

gdalle commented Oct 11, 2024

Alternatively, or in complement to this PR, I've been thinking of adding a batch size parameter to the Enzyme AD type, so that it can be statically inferred like in AutoForwardDiff. But maybe I should read the Width from the mode object instead? Is it the same?

@wsmoses
Copy link
Member

wsmoses commented Oct 11, 2024 via email

@gdalle
Copy link
Contributor Author

gdalle commented Oct 12, 2024

On the other hand maybe this should be an adaptive function which dispatches on the array type, so that static arrays can get special treatment?

@gdalle gdalle marked this pull request as draft October 12, 2024 11:11
@gdalle
Copy link
Contributor Author

gdalle commented Oct 12, 2024

Actually I'm gonna put this on hold until I get a better sense of what it means to choose a batch size. I'll try to write something up for the DI docs and then go from there. Please don't merge in the meantime.

@gdalle gdalle closed this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Heuristic for picking the chunk/batch size?
4 participants